URL := https://chenlongos.cn/redox/release/harddrive.img
IMG := harddrive.img

URL2 := https://chenlongos.cn/redox/release/livedisk.iso
IMG2 := livedisk.iso

all: $(IMG)
	SDL_VIDEO_X11_DGAMOUSE=0 qemu-system-x86_64 -d cpu_reset,guest_errors -smp 4 -m 1G -chardev stdio,id=debug,signal=off,mux=on,"" -serial chardev:debug -mon chardev=debug -machine q35 -device ich9-intel-hda -device hda-duplex -netdev user,id=net0 -device e1000,netdev=net0 -device nec-usb-xhci,id=xhci -drive file=./harddrive.img,format=raw -nographic

gui: $(IMG)
	SDL_VIDEO_X11_DGAMOUSE=0 qemu-system-x86_64 -d cpu_reset,guest_errors -smp 4 -m 1G -chardev stdio,id=debug,signal=off,mux=on,"" -serial chardev:debug -mon chardev=debug -machine q35 -device ich9-intel-hda -device hda-duplex -netdev user,id=net0 -device e1000,netdev=net0 -device nec-usb-xhci,id=xhci -drive file=./harddrive.img,format=raw

burn: $(IMG2)
	@echo '--- make sure your u-disk info and copy the command below to execute by yourself for safety ---'
	@echo '$$ diskutil list'
	@echo '$$ sudo dd if=./livedisk.iso of=/dev/disk3 bs=1m'

.PHONY: download
download: $(IMG) $(IMG2)
	@echo $(IMG) is found, no need to download
	@echo $(IMG2) is found, no need to download

$(IMG):
	@echo "Downloading $(URL)..."
	wget $(URL)

$(IMG2):
	@echo "Downloading $(URL2)..."
	wget $(URL2)

clean:
	@rm -rf $(IMG)
	@rm -rf $(IMG2)